from django.conf.urls import patterns, include, url
from viewer.views import *
from viewer.json_get import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('viewer.views',
    # Examples:
    # url(r'^$', 'tdm_viewer.views.home', name='home'),
    # url(r'^tdm_viewer/', include('tdm_viewer.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
    # view main frame web page
    url(r'^$', 'view_tdm_index'),
    url(r'^tdm/login/$', 'view_tdm_login'),
    url(r'^tdm/logout/$', 'view_tdm_logout'),
    url(r'^tdm/main/$', 'view_tdm_main'),
    url(r'^tdm/main/(?P<city>\w+)$', 'view_tdm_main'),
    url(r'^tdm/log/$', 'view_server_log'),
    url(r'^tdm/profile/$', 'view_tdm_profile'),

    # view admin web page
    url(r'^tdm/admin/$', 'tdm_admin'),
    url(r'^tdm/admin/city/$', 'tdm_admin_city'),
    url(r'^tdm/admin/venue/$', 'tdm_admin_venue'),
    url(r'^tdm/admin/venue/(?P<city>\w+)/$', 'tdm_admin_venue'),
    url(r'^tdm/admin/power/$', 'tdm_admin_power_cfg'),
    url(r'^tdm/admin/power/(?P<city>\w+)/$', 'tdm_admin_power_cfg'),
    url(r'^tdm/admin/power/(?P<city>\w+)/(?P<venue>\w+)/$', 'tdm_admin_power_cfg'),
    url(r'^tdm/admin/network/$', 'tdm_admin_network_cfg'),
    url(r'^tdm/admin/network/(?P<city>\w+)/$', 'tdm_admin_network_cfg'),
    url(r'^tdm/admin/network/(?P<city>\w+)/(?P<venue>\w+)/$', 'tdm_admin_network_cfg'),
    url(r'^tdm/admin/server/$', 'tdm_admin_server_cfg'),
    url(r'^tdm/admin/server/(?P<city>\w+)/$', 'tdm_admin_server_cfg'),
    url(r'^tdm/admin/server/(?P<city>\w+)/(?P<venue>\w+)/$', 'tdm_admin_server_cfg'),
    url(r'^tdm/admin/mdm/$', 'tdm_admin_mdm_cfg'),
    url(r'^tdm/admin/mdm/(?P<city>\w+)/$', 'tdm_admin_mdm_cfg'),
    url(r'^tdm/admin/mdm/(?P<city>\w+)/(?P<venue>\w+)/$', 'tdm_admin_mdm_cfg'),
    url(r'^tdm/admin/acard/$', 'tdm_admin_acard_cfg'),
    url(r'^tdm/admin/acard/(?P<city>\w+)/$', 'tdm_admin_acard_cfg'),
    url(r'^tdm/admin/acard/(?P<city>\w+)/(?P<venue>\w+)/$', 'tdm_admin_acard_cfg'),
    url(r'^tdm/admin/alert/$', 'tdm_admin_alert_cfg'),
    url(r'^tdm/admin/user/$', 'tdm_admin_user_cfg'),
    url(r'^tdm/admin/dev/$', 'tdm_admin_dev'),
    url(r'^tdm/admin/autocmd/$', 'tdm_admin_autocmd'),
    url(r'^tdm/admin/autocmd/add/$', 'tdm_admin_autocmd_add'),
    url(r'^tdm/admin/autocmd/del/$', 'tdm_admin_autocmd_del'),
    url(r'^tdm/admin/autocmd/list/$', 'tdm_admin_autocmd_list'),

    # view report web pages
    url(r'^tdm/report/$', 'view_tdm_report'),
    url(r'^tdm/report/ctm_error/$', 'view_tdm_report_ctm_error'),
    url(r'^tdm/report/credit_card/$', 'view_tdm_report_credit_card'),
    
    # view power web page
    url(r'^tdm/power/$', 'view_power_item'),
    url(r'^tdm/power/(?P<city>\w+)/$', 'view_power_item'),
    url(r'^tdm/power/(?P<city>\w+)/(?P<venue>\w+)/$', 'view_power_item'),

    # view server web page
    url(r'^tdm/server/$', 'view_server_item'),
    url(r'^tdm/server/item/$', 'view_server_item'),
    url(r'^tdm/server/(?P<city>\w+)/$', 'view_server_item'),
    url(r'^tdm/server/(?P<city>\w+)/(?P<venue>\w+)/$', 'view_server_item'),
    url(r'^tdm/server/(?P<city>\w+)/(?P<venue>\w+)/(?P<dev>\w+)/$', 'view_server_item_detail'),

    # view network web page
    url(r'^tdm/network/$', 'view_network_item'),
    url(r'^tdm/network/(?P<city>\w+)/$', 'view_network_item'),
    url(r'^tdm/network/(?P<city>\w+)/(?P<venue>\w+)/$', 'view_network_item'),
    url(r'^tdm/network/(?P<city>\w+)/(?P<venue>\w+)/(?P<dev>\w+)/$', 'view_network_item_detail'),

    # view mdm web page
    url(r'^tdm/mdm/$', 'view_mdm_item'),
    url(r'^tdm/mdm/(?P<city>\w+)/$', 'view_mdm_item'),
    url(r'^tdm/mdm/(?P<city>\w+)/(?P<venue>\w+)/$', 'view_mdm_item'),
    url(r'^tdm/mdm/(?P<city>\w+)/(?P<venue>\w+)/(?P<classroom>\w+)/$', 'view_mdm_item_detail'),

    # view acard web page
    url(r'^tdm/acard/$', 'view_acard_item'),
    url(r'^tdm/acard/(?P<city>\w+)/$', 'view_acard_item'),
    url(r'^tdm/acard/(?P<city>\w+)/(?P<venue>\w+)/$', 'view_acard_item'),
    url(r'^tdm/acard/(?P<city>\w+)/(?P<venue>\w+)/(?P<ctmdev>\w+)/$', 'view_acard_item_detail'),
)

urlpatterns += patterns('viewer.json_get',
    # request json data
    url(r'^tdm/json/city/$', 'view_get_json_city'),
    url(r'^tdm/json/venue/(?P<city>\w+)/$', 'view_get_json_venue'),
    url(r'^tdm/json/acard/venuesync/(?P<city>\w+)/$', 'view_get_json_acard_venuesynclog_info'),
    url(r'^tdm/json/acard/venuesync/(?P<city>\w+)/(?P<venue>\w+)/(?P<ctmdev>\w+)/$', 'view_get_json_acard_ctmdevlog_info'),
    url(r'^tdm/json/report/ctm_error/(?P<city>\w+)/(?P<start_date>[\d-]+)/(?P<end_date>[\d-]+)/$', 'view_get_json_report_ctm_error'),
    url(r'^tdm/json/report/credit_card/(?P<city>\w+)/(?P<start_date>[\d-]+)/(?P<end_date>[\d-]+)/$', 'view_get_json_report_credit_card'),
    # get ctm client last version and url
    url(r'^json/get_ctm_client', 'view_get_json_ctm_client'),
    url(r'^tdm/json/acard/client/$', 'view_get_json_ctm_client'),
    url(r'^json/get_ams_client_ver$', 'view_get_json_ams_client_ver'),
)

urlpatterns += patterns('viewer.auth',
    url(r'^show_color/$', 'show_color'),
    url(r'^set_color/$', 'set_color'),
    url(r'^post_comment/$', 'post_comment'),
)
